local skynet = require "skynet"

skynet.start(function()
    local gate = skynet.newservice("mymsgserver") 
    --网关服务需要发送lua open来打开，open也是保留的命令
    skynet.call(gate, "lua", "open" , {
        port = 8002,
        maxclient = 64,
        servername = "sample",  --取名叫sample，跟使用skynet.name(".sample")一样
    })
  
    local uid = "nzhsoft"
    local secret = "11111111"
    local subid = skynet.call(gate, "lua", "login", uid, secret) --告诉msgserver，nzhsoft这个用户可以登陆
    skynet.error("lua login subid", subid)
        
    skynet.call(gate, "lua", "logout", uid, subid) --告诉msgserver，nzhsoft登出
        
    skynet.call(gate, "lua", "kick", uid, subid) --告诉msgserver，剔除nzhsoft连接
   
    skynet.call(gate, "lua", "close")   --关闭gate，也就是关掉监听套接字

end)

-- openmymsgserver
-- [:0100000a] LAUNCH snlua sendtomsgserver
-- [:0100000b] LAUNCH snlua simplemsgserver
-- [:0100000b] Listen on 0.0.0.0:8002
-- [:0100000b] register_handler invoked name sample
-- [:0100000b] login_handler invoke nzhsoft 11111111       #login_handler调用
-- [:0100000b] uid nzhsoft login，username bnpoc29mdA==@c2FtcGxl#MQ==   #login_handler调用成功，并生成一个登陆名
-- [:0100000a] lua login subid 1 #返回一个唯一的subid
-- [:0100000b] logout_handler invoke nzhsoft 1 #登出调用
-- [:0100000b] kick_handler invoke nzhsoft 1   #kick_handler调用
